package org.yiqixue.accounts.mapper;

import org.yiqixue.accounts.dto.TransactionDto;
import org.yiqixue.accounts.entity.Transaction;

public class TransactionMapper {

    /**
     * 将 Transaction 实体类转换为 TransactionDto
     * @param transaction Transaction 实体类
     * @return 转换后的 TransactionDto
     */
    public static TransactionDto mapToTransactionDto(Transaction transaction) {
        TransactionDto transactionDto = new TransactionDto();
        transactionDto.setTransactionID(transaction.getTransactionID());
        transactionDto.setAccountNumber(transaction.getAccountNumber());
        transactionDto.setAmount(transaction.getAmount());
        transactionDto.setTransactionDate(transaction.getTransactionDate());
        transactionDto.setDescription(transaction.getDescription());
        transactionDto.setStatus(transaction.getStatus());
        transactionDto.setType(transaction.getType());
        return transactionDto;
    }

    /**
     * 将 TransactionDto 转换为 Transaction 实体类
     * @param transactionDto TransactionDto
     * @param transaction Transaction 实体类
     * @return 转换后的 Transaction 实体类
     */
    public static Transaction mapToTransaction(TransactionDto transactionDto, Transaction transaction) {
        transaction.setTransactionID(transactionDto.getTransactionID());
        transaction.setAccountNumber(transactionDto.getAccountNumber());
        transaction.setAmount(transactionDto.getAmount());
        transaction.setTransactionDate(transactionDto.getTransactionDate());
        transaction.setDescription(transactionDto.getDescription());
        transaction.setStatus(transactionDto.getStatus());
        transaction.setType(transactionDto.getType());
        return transaction;
    }
}